package com.create.table.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.gitee.sunchenbin.mybatis.actable.annotation.*;
import lombok.Data;

import static com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant.*;

@Data
@TableName(value = "test")
public class Test {

    @Column(name = "id", type = BIGINT, isNull = false, isKey = true, comment = "id")
    @IsKey
    @IsAutoIncrement
    private Long id;


    @TableField(value = "name")
    @Column(name = "name", type = VARCHAR, length = 64, comment = "名称")
    private String name;


    /**
     * IsNativeDefValue：开启默认值原生模式
     * 原生模式介绍：默认是false表示非原生，此时value只支持字符串形式，会将value值以字符串的形式设置到字段的默认值，例如value="aa" 即sql为 DEFAULT "aa"
     * 如果设置isNative=true，此时如果value="CURRENT_TIMESTAMP"，即sql为 DEFAULT CURRENT_TIMESTAMP
     */
    @TableField(value = "create_time")
    @DefaultValue(value = "CURRENT_TIMESTAMP")
    @IsNativeDefValue
    @Column(name = "create_time", type = TIMESTAMP, isNull = false, comment = "创建时间")
    private String creatTime;
    /**
     * IsNativeDefValue：开启默认值原生模式
     * 原生模式介绍：默认是false表示非原生，此时value只支持字符串形式，会将value值以字符串的形式设置到字段的默认值，例如value="aa" 即sql为 DEFAULT "aa"
     * 如果设置isNative=true，此时如果value="CURRENT_TIMESTAMP"，即sql为 DEFAULT CURRENT_TIMESTAMP
     */
    @TableField(value = "update_time")
    @DefaultValue(value = "CURRENT_TIMESTAMP")
    @IsNativeDefValue
    @Column(name = "update_time", type = TIMESTAMP, isNull = false, comment = "更新时间")
    private String updateTime;
}